package cn.xiaopengstack.domain.strategy.service.rule.chain.impl;

import cn.xiaopengstack.domain.strategy.model.entity.RuleChainMatterEntity;
import cn.xiaopengstack.domain.strategy.service.rule.chain.factory.DefaultLogicChainFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author jiangyangang
 */
@Component("rule_default")
@Slf4j
public class DefaultRuleChainImpl extends AbstractLogicChain{
    @Override
    protected DefaultLogicChainFactory.LogicModel ruleModel() {
        return DefaultLogicChainFactory.LogicModel.RULE_DEFAULT;
    }

    @Override
    public DefaultLogicChainFactory.StrategyAwardVO doChain(RuleChainMatterEntity ruleChainMatterEntity) {
        // 执行抽奖
        Integer awardId = strategyDispatch.getRandomAwardId(ruleChainMatterEntity.getStrategy().getStrategyId());
        return DefaultLogicChainFactory.StrategyAwardVO.builder()
                .awardId(awardId)
                .takeOverRule(ruleModel())
                .strategyId(ruleChainMatterEntity.getStrategy().getStrategyId())
                .build();
    }
}
